package request

type SysRoleCreateRequest struct {
	Name    string `json:"name" binding:"required" label:"角色名称"`
	Code    string `json:"code" binding:"required" label:"角色编码"`
	Sort    int    `json:"sort" label:"排序"`
	Status  int    `json:"status" binding:"oneof=0 1" label:"状态"`
	MenuIds []uint `json:"menu_ids" label:"菜单ID列表"`
	Remark  string `json:"remark" label:"备注"`
}

func (sysRoleCreateRequest SysRoleCreateRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"Name.required": "角色名称不能为空",
		"Code.required": "角色编码不能为空",
	}
}

type SysRoleBatchDeleteRequest struct {
	IDs []uint `json:"ids" binding:"required,min=1" label:"角色ID列表"`
}

func (sysRoleBatchDeleteRequest SysRoleBatchDeleteRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"IDs.required": "角色ID列表不能为空",
		"IDs.min":      "角色ID列表不能为空",
	}
}

type SysRoleUpdateRequest struct {
	ID      uint   `json:"id" binding:"required" label:"角色ID"`
	Name    string `json:"name" binding:"required" label:"角色名称"`
	Code    string `json:"code" binding:"required" label:"角色编码"`
	Sort    int    `json:"sort"  label:"排序"`
	Status  int    `json:"status" binding:"oneof=0 1" label:"状态"`
	Remark  string `json:"remark" label:"备注"`
	MenuIds []uint `json:"menu_ids" label:"菜单ID列表"`
}

func (sysRoleUpdateRequest SysRoleUpdateRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"ID.required":   "角色ID不能为空",
		"Name.required": "角色名称不能为空",
		"Code.required": "角色编码不能为空",
		"Status.oneof":  "状态只能是0或1",
	}
}

type SysRolePageRequest struct {
	Name   string `json:"name" form:"name"`     // 角色名称
	Code   string `json:"code" form:"code"`     // 角色编码
	Status *int   `json:"status" form:"status"` // 状态
	PageInfo
}

func (sysRolePageRequest SysRolePageRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"Name.required": "角色名称不能为空",
		"Code.required": "角色编码不能为空",
		"Status.oneof":  "状态只能是0或1",
	}
}

type SysRoleAssignRequest struct {
	UserId  uint   `json:"user_id" binding:"required" label:"用户ID"`
	RoleIds []uint `json:"role_ids" binding:"required" label:"角色ID列表"`
}

func (sysRoleAssignRequest SysRoleAssignRequest) GetMessages() ValidatorMessages {
	return ValidatorMessages{
		"UserId.required":  "用户ID不能为空",
		"RoleIds.required": "角色ID列表不能为空",
	}
}
